import { getOfficeMenuList } from '@/apis/office'
import { getMenus, setMenus } from '@/utils/storage'

const state = {
  menus: getMenus() || [],
}

const mutations = {
  SET_MENUS: (state, payload) => {
    state.menus = payload
    setMenus(payload)
  },
}

const actions = {
  async fetchMenus({ commit }) {
    const { data } = await getOfficeMenuList()
    console.log(data, '菜单列表')
    commit('SET_MENUS', data)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
